package com.mark;

import java.util.ArrayList;
import java.util.List;

/**
 * @Description: Javac 命令请求参数构建器
 * @Author: Mark
 * @CreateDate: 2021/12/25 16:08
 * @Copyright : 豆浆油条个人非正式工作室
 */
public class JavacArgsBuilder {

    public static class Builder {

        private final List<String> argsList = new ArrayList<>();

        public Builder addArgs(String arg) {
            this.argsList.add(arg);
            return this;
        }

        public String[] args(){
            String[] result = new String[argsList.size()];
            argsList.toArray(result);
            return result;
        }
    }

    public static Builder createOfDefaultOutDir() {
        Builder builder = new Builder();
        builder.argsList.add(Constant.D);
        builder.argsList.add(Constant.JAVAC_OUTPUT_CLASS_PATH);
        return builder;
    }
}
